<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>以方法访问函数属性</title>
</head>

<body>
    <h1>JavaScript 对象方法</h1>
    <p>对象方法是一种函数定义，存储为属性值。</p>
    <p id="demo"></p>
    <script>
        // 创建对象：
        var person = {
            firstName: "wang",
            lastName: "yufei",
            id: 1231231,
            fullName: function () {
                return this.firstName + " " + this.lastName;
            }
        };
        //显示对象中的数据：
        document.getElementById("demo").innerHTML = person.fullName();
    </script>
</body>

</html>